<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>面积图</title>
  <link rel="stylesheet" href="./assets/common.css">
</head>
<body>
<div>
  <canvas id="mountNode"></canvas>
</div>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="../build/f2-all.js"></script>
<script>
  const data = [
    { time: '2016-08-08 00:00:00', tem: 10, city: 'beijing' },
    { time: '2016-08-08 00:10:00', tem: 22, city: 'beijing' },
    { time: '2016-08-08 00:30:00', tem: 16, city: 'beijing' },
    { time: '2016-08-09 00:35:00', tem: 26, city: 'beijing' },
    { time: '2016-08-09 01:00:00', tem: 12, city: 'beijing' },
    { time: '2016-08-09 01:20:00', tem: 26, city: 'beijing' },
    { time: '2016-08-10 01:40:00', tem: 18, city: 'beijing' },
    { time: '2016-08-10 02:00:00', tem: 26, city: 'beijing' },
    { time: '2016-08-10 02:20:00', tem: 12, city: 'beijing' },
    { time: '2016-08-08 00:00:00', tem: 28, city: 'newYork' },
    { time: '2016-08-08 00:10:00', tem: 16, city: 'newYork' },
    { time: '2016-08-08 00:30:00', tem: 26, city: 'newYork' },
    { time: '2016-08-09 00:35:00', tem: 12, city: 'newYork' },
    { time: '2016-08-09 01:00:00', tem: 26, city: 'newYork' },
    { time: '2016-08-09 01:20:00', tem: 20, city: 'newYork' },
    { time: '2016-08-10 01:40:00', tem: 29, city: 'newYork' },
    { time: '2016-08-10 02:00:00', tem: 16, city: 'newYork' },
    { time: '2016-08-10 02:20:00', tem: 22, city: 'newYork' }
  ];
  const chart = new F2.Chart({
    id: 'mountNode',
    width: window.innerWidth,
    height: window.innerWidth * 0.64,
    pixelRatio: window.devicePixelRatio
  });
  chart.source(data, {
    time: {
      type: 'timeCat',
      tickCount: 3,
      range: [ 0, 1 ]
    },
    tem: {
      tickCount: 5,
      min: 0
    }
  });

  chart.axis('time', {
    label(text, index, total) {
      const textCfg = {};
      if (index === 0) {
        textCfg.textAlign = 'left';
      }
      if (index === total - 1) {
        textCfg.textAlign = 'right';
      }
      return textCfg;
    }
  });
  chart.area().position('time*tem')
    .color('city')
    .shape('smooth');
  chart.line().position('time*tem')
    .color('city')
    .shape('smooth');
  chart.render();
</script>
</body>
</html>
